<template>
  <div id="bookmark">
    <span v-if="!hasData" style="position:relative;font-size: 10px;">没有数据</span>
    <div v-for="item in bookmarks" v-else :key="item._id" class="layer-arguments">
      <a class="el-icon-location"/>
      <span @click="locateTo(item)">&nbsp;{{ item.name }}&nbsp;&nbsp;&nbsp;</span>
      <a class="bookmarkDel kfb-icon-icon-test62" @click="handleDelete(item)"/>
      <a class="bookmarkDel kfb-icon-bianji2" @click="handleEdit(item)"/>
    </div>
  </div>
</template>

<script>
  import { add, remove, update, list } from '@/api/bookmark'
  import { mapState } from 'vuex'
  export default {
    name: 'BookMark',
    data() {
      return {
        bookmarks: [] // 书签数据
      }
    },
    methods: {
      /**
       * 获取书签列表
       */
      getBookMarks() {
        const mapModuleIndex = this.mapModuleIndex
        switch (mapModuleIndex) {
          case 0:
            list({ type: 0, uid: this.$store.getters.id }).then(res => {
              this.bookmarks = res.data
            })
            break
          case 1:
            list({ type: 1, uid: this.$store.getters.id }).then(res => {
              this.bookmarks = res.data
            })
            break
          case 2:
            list({ type: 0, uid: this.$store.getters.id }).then(res => {
              this.bookmarks = res.data
            })
            break
        }
      }
    },
    computed: {
      ...mapState({
        // 地图模块控件
        mapModuleIndex(state) {
          return state.eswyzt.mapModuleIndex
        },

        mapService(state) {
          return state.eswyzt.mapService
        }
      }),
      // 书签是否有数据
      hasData() {
        return this.bookmarks.length > 0
      }
    }
  }
</script>

<style scoped>
  #bookmark{
    height: 100%;
  }
  #bookmark .layer-arguments {
    margin-top: 4px;
    height: 23px;
    line-height: 23px;
    border-bottom: 1px solid #eee;
  }
</style>
